<template>
	<view class="contain">
		<uni-header></uni-header>
		<view class="padding-15">
			<view class="padding-15 b-color-e">
				<view class="padding-15 flex f-j-c f-w-500 f16-size">
					Order Successfully,please pay
				</view>
				<view class="bg-color-e padding-15 margin-t16">
					<view class="flex f-a-c f-j-s">
						<view class="flex f-a-c ">
							<text class="margin-r12">Order Number:</text>
							<text class="f-w-500">{{id}}</text>
						</view>
						<view class="flex f-a-c ">
							<text class="margin-r12">Amount:</text>
							<text class="text-price f-w-500">{{amount}}</text>
						</view>
					</view>
					<view class="flex f-a-c  margin-t10">
						Payment Method: <text class="f-w-500">PayPal</text>
					</view>
				</view>
			</view>
			<view class="padding-15"></view>
			<view @click="getPay" class="flex f-a-c f-j-c f-w-500 t-color-w f16-size h-44 bg-color-0">
				<image class="w-50" src="../../static/images/paypal_w.png" mode="widthFix"></image>
			</view>
		</view>
		
	</view>
</template>
<style scoped>
</style>
<script>
	const $ = require('@/utils/api.js');
	let self = this;
	export default {
		components: {},
		data() {
			return {
				id: '',
				amount: '',
				token: ''
			};
		},
		onLoad: function(options) {
			self = this;
			this.id = options.id ? options.id : '10000';
			this.amount = options.amount ? options.amount : '0';
			this.token = options.token ? options.token : '';
			this.init();
		},
		onShow() {
		},
		methods: {
			getPay() {
				$.ajax({
					url: '/v1/tk_shop/user/order/pay',
					data: {
						order_id: this.id
					},
					loading:true,
					method: 'POST',
					success(res) {
						let url = res.data.link ? res.data.link : '';
						window.location.href = url;
					}
				})
			},
			payStatus() {
				$.ajax({
					url: '/v1/tk_shop/user/order/pay_capture',
					data: {paypal_token:this.token},
					method: 'POST',
					loading:true,
					success(res) {
						self.go('/pages/index/orderList',3);
					}
				})
			},
			init() {
				if(this.token != ''){
					this.payStatus();
				}
			},
		},
		computed: {},
		created() {
		},
		mounted() {},
		destroyed() {},
		onPullDownRefresh() {
		},
		onReachBottom() {
			
		}
	}
</script>